package com.udata.server.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.udata.shared.model.UserProfileB;

@PersistenceCapable
public class UserProfile {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private String sex;

	@Persistent
	private String country;

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public UserProfile(UserProfileB userProfileB) {
		this.update(userProfileB);
	}

	public void update(UserProfileB userProfileB) {
		this.sex = userProfileB.getSex();
		this.country = userProfileB.getCountry();
	}

	public UserProfileB getBean() {
		UserProfileB userProfileB = new UserProfileB();
		userProfileB.setKey(KeyFactory.keyToString(key));
		userProfileB.setSex(sex);
		userProfileB.setCountry(country);
		return userProfileB;
	}
}
